package com.atguigu.test;

import org.apache.http.HttpHost;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;

import java.io.IOException;

public class test_es_09_doc_bulk_delete {

    public static void main(String[] args) throws IOException {

        //创建es客户端
        RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(new HttpHost("127.0.0.1",9200,"http")));

        BulkRequest bulkRequest = new BulkRequest();

        bulkRequest.add(new DeleteRequest("user").id("1001"));
        bulkRequest.add(new DeleteRequest("user").id("1002"));

        //批量删除、发送请求
        esClient.bulk(bulkRequest, RequestOptions.DEFAULT);

        //关闭es客户端
        esClient.close();;
    }
}
